Ext.define('js.ranInsOfProQui.RandomInspectionOfQualityAssuranceSystemPage', {
    extend: 'Ext.grid.Panel',
    id:'RandomInspectionOfQualityAssuranceSystemPage',
    requires: ['js.Util', 'js.ctrl.Common',],
    controller: 'Common',
    autoScroll : true,
    margin:'0 30 30 30',
    height:508,
    bodyStyle: {
        backgroundColor: '#eee',
    },
    initComponent: function () {
        this.store = Ext.create('js.store.ranInsOfProQui.RandomInspectionOfQualityAssuranceSystemStore');
          this.store.getProxy().setExtraParam('pageNum', 1);
        this.store.getProxy().setExtraParam('check_type', 1);
        this.store.getProxy().setExtraParam('engineering_id',this.engineering_id);
          this.store.load({
              callback:function () {
                  let me = Ext.getCmp('RandomInspectionOfQualityAssuranceSystemPage');
                  if(me){
                      if(me.store.data.items.length>0){
                          new Page({
                              id: 'paginationSupplierB',
                              pageTotal: me.store.data.items[0].data.pageTotal, //必填,总页数
                              pageAmount: 10,  //每页多少条
                              dataTotal: me.store.data.items[0].data.dataTotal, //总共多少条数据
                              curPage:parseInt(me.store.data.items[0].data.pageNum), //初始页码,不填默认为1
                              pageSize: 5, //分页个数,不填默认为5
                              showPageTotalFlag:true, //是否显示数据统计,不填默认不显示
                              showSkipInputFlag:true, //是否支持跳转,不填默认不显示
                              getPage: function (page) {
                                  //获取当前页数
                                  me.store.getProxy().setExtraParam('pageNum', page);
                                  me.store.reload();
                              }
                          })
                      }else{
                          new Page({
                              id: 'paginationSupplier',
                              pageTotal: 1, //必填,总页数
                              pageAmount: 10,  //每页多少条
                              dataTotal: 0, //总共多少条数据
                              pageSize: 5, //分页个数,不填默认为5
                              showPageTotalFlag:true, //是否显示数据统计,不填默认不显示
                              showSkipInputFlag:true, //是否支持跳转,不填默认不显示
                              getPage: function (page) {
                                  //获取当前页数
                                  me.store.getProxy().setExtraParam('pageNum', page);
                                  me.store.reload();
                              }
                          })
                      }
                  }
              }
          });
        this.columns = [
            {text: '日期', dataIndex: 'check_date', align: 'center', flex: 1},
            {text: '对象单位', dataIndex: 'unit_name', align: 'center', flex: 1},
            {text: '是否下发整改', dataIndex: 'check_result', align: 'center', flex: 1},
            {text: '是否回复', dataIndex: 'reply_result', align: 'center', flex: 1,},
            {text: '抽查人员', dataIndex: 'user_name', align: 'center', flex: 1,},
            {
                text: "操作", dataIndex: 'user_id',
                flex: 1,
                align: 'center',
                action_type: 'projectMergerAdd',
                renderer: function (value, cellmeta, record, rowIndex, columnIndex, store) {//自定义列值组合
                    return '<span style="margin-right:20px;color:#2672d9;font-size: 17px;letter-spacing: 1px;cursor:pointer;"><a href="#" style="text-decoration:none;" onclick="xiangqing(' + JSON.stringify(record.data).replace(/\"/g, "'") + ')">详情</a></span> <span style="margin-right:20px;color:#ff8041;font-size: 17px;letter-spacing: 1px;cursor:pointer;"> <a href="#" style="text-decoration:none;" onclick="upd(' + JSON.stringify(record.data).replace(/\"/g, "'") + ')">编辑</a></span><span style="margin-right:20px;color:#ff8041;font-size: 17px;letter-spacing: 1px;cursor:pointer;"><a  href="#" style="text-decoration:none;"  onclick="del(' + JSON.stringify(record.data).replace(/\"/g, "'") + ')">删除</a> </span>';
                },height:44
            },
        ];
        this.dockedItems = [
            { xtype: 'panel',
                html:'<div id="paginationSupplierB" class="pagination"></div>',
                dock: 'bottom',
                height:50,
                margin:'-14 0 0 0',
                displayInfo: true,
            }];
        this.on('cellclick', this.cellclick);
        this.callParent(arguments);
    },
    cellclick: function (td, cellIndex, record, tr, rowIndex, e, eOpts) {
        if (record === 1 || record === 8) {
            let params = {
                action_type: 'accumulatorQuery',
                region_id: tr.data.region_id,
                region_name: tr.data.region_name
            };
            util.sysPanelAdd('js.information.InformationListMain', params);
        }
    },
});